<script  src="/assets/js/jquery.min.js"></script>
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<!--
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Store_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-store_id" data-rule="required" data-source="store/index" class="form-control selectpage form-control" name="row[store_id]" type="text" value="">
        </div>
    </div>-->
    <div class="form-group"  id="one_class">
        <label class="control-label col-xs-12 col-sm-2">{:__('一级分类')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select class="form-control form-control" required="" name="row[classes_id]" id="one">
                <option value="0">请选择</option>
                {foreach name="classes" item='val'}
                <option value="{$val.id}">{$val.names}</option>
                {/foreach}
            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Names')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-names" data-rule="required" class="form-control form-control" name="row[names]" type="text" value="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Keyword')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-keyword" data-rule="required" class="form-control form-control" name="row[keyword]" type="text" value="">
        </div>
    </div>

    <!--<div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Classes_name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-classes_name" data-rule="required" class="form-control form-control" name="row[classes_name]" type="text" value="">
        </div>
    </div>-->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Goods_jingle')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-goods_jingle" data-rule="required" class="form-control form-control" name="row[goods_jingle]" type="text" value="">
        </div>
    </div>
   <!-- <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Goods_attr_index_ids')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-goods_attr_index_ids" data-rule="required" data-source="goods/attr/index/index" data-multiple="true" class="form-control selectpage form-control" name="row[goods_attr_index_ids]" type="text" value="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Spec_value_ids')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-spec_value_ids" data-rule="required" data-source="spec/value/index" data-multiple="true" class="form-control selectpage form-control" name="row[spec_value_ids]" type="text" value="">
        </div>
    </div>-->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Price')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-money" data-rule="required" class="form-control form-control" step="0.01" name="row[price]" type="number" value="0.00">
        </div>
    </div>

   <!-- <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Discount_price')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-discount_price" data-rule="required" class="form-control form-control" step="0.01" name="row[discount_price]" type="number" value="0.00">
        </div>
    </div>-->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Pic')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-image" class="form-control" size="50" name="row[pic]" type="text">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="plupload-image" class="btn btn-danger plupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-image"></span>
            </div>
            <ul class="row list-inline plupload-preview" id="p-image"></ul>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('商品轮播图')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-pic" class="form-control" size="50" name="row[small_pic]" type="text">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="plupload-pic" class="btn btn-danger plupload" data-input-id="c-pic" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-pic"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-pic" class="btn btn-primary fachoose" data-input-id="c-pic" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-pic"></span>
            </div>
            <ul class="row list-inline plupload-preview" id="p-pic"></ul>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-content" class="form-control editor form-control" rows="5" name="row[content]" cols="50"></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Sort')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-sort" data-rule="required" class="form-control form-control" name="row[sort]" type="number" value="0">
        </div>
    </div>

   <!-- <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Reason')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-reason" data-rule="required" class="form-control form-control" name="row[reason]" type="text" value="">
        </div>
    </div>-->
    <!--<div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Goods_verify')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select  id="c-goods_verify" data-rule="required" class="form-control selectpicker" name="row[goods_verify]">
                {foreach name="goodsVerifyList" item="vo"}
                <option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option>
                {/foreach}
            </select>
        </div>
    </div>-->

  <!--  <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Goods_verifyremark')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-goods_verifyremark" data-rule="required" class="form-control form-control" name="row[goods_verifyremark]" type="text" value="">
        </div>
    </div>-->

    <!--<div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Storage')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-storage" data-rule="required" class="form-control form-control" name="row[storage]" type="number" value="0">
        </div>
    </div>-->
    <!--<div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Sale')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-sale" data-rule="required" class="form-control form-control" name="row[sale]" type="number" value="0">
        </div>
    </div>-->
   <!-- <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Types')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-types" data-rule="required" class="form-control form-control" name="row[types]" type="number" value="1">
        </div>
    </div>-->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Is_recomment')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select  id="c-is_recomment" data-rule="required" class="form-control selectpicker" name="row[is_recomment]">
                {foreach name="isRecommentList" item="vo"}
                <option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option>
                {/foreach}
            </select></div>
    </div>


    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed ">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
<script>
    $('#one_class').change(function(){
        var pid=$('#one').val();

        var object=$(this);

        if(pid>0){
            $.ajax({
                'url':'{:url("/admin/goodscommon/Goodscommon/getClasses")}',
                'data':{'pid':pid},
                'async':true,
                'type':'post',
                'dateType':'json',
                success:function(res){
                    if(res.status){
                        if(res.data){
                            object.after(res.data);
                            $('#two_class').change(function () {

                                var class_id=$('#two').val();
                              //  console.log(class_id);
                                if(class_id!=0){
                                    var object=$('#two_class');
                                    getClassAttr(object,class_id);
                                }

                                $('#three').remove();
                            })
                        }else{

                            getClassAttr(object,pid);
                        }
                    }
                }
            })
        }
        $('#two_class').remove();
        $('#three').remove();
    })

    function getClassAttr(object,class_id) {
       // var class_id=$('#two').val();
        //console.log(class_id);
        if(class_id){
            $.ajax({
                'url':'{:url("/admin/goodscommon/Goodscommon/getClassesAttr")}',
                'data':{'class_id':class_id},
                'async':true,
                'type':'post',
                'dateType':'json',
                success:function(res){
                    if(res.status){
                        if(res.data){
                           object.after(res.data);
                        }
                    }
                }
            })
        }
    }
</script>